#pragma once

#include <chrono>

namespace solar
{
    constexpr auto getDayOfTheYear(int year, unsigned int month, unsigned int day) -> int
    {
        std::chrono::year_month_day current_day{std::chrono::year(year), std::chrono::month(month),
                                                std::chrono::day(day)};
        std::chrono::year_month_day day_start{std::chrono::year(year), std::chrono::month(1),
                                              std::chrono::day(1)};
        return std::chrono::local_days(current_day).time_since_epoch().count() -
               std::chrono::local_days(day_start).time_since_epoch().count();
    }

    template <typename Duration>
    constexpr auto toHours(const std::chrono::hh_mm_ss<Duration>& current_time) -> double
    {
        double hours = current_time.hours().count();
        double minutes = current_time.minutes().count();
        double seconds = current_time.seconds().count();
        return hours + minutes / 60.0 + seconds / 3600.0;
    }
} // namespace solar
